package org.example.bookingsystem.controller;

import jakarta.servlet.http.HttpServletRequest;
import org.example.bookingsystem.service.BankService;
import org.example.bookingsystem.utils.JwtUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/bank")
public class BankController {
    @Autowired
    private BankService bankService;
    @RequestMapping("/getBalance")
    public int getBalance(HttpServletRequest request){
        String token =request.getHeader("user_token");
        int uid = JwtUtils.getUserIdFromToken(token);
        return bankService.getBalance(uid);
    }

}
